package cn.com.twoke.application.game.mario.game.component;

import cn.com.twoke.application.game.mario.core.ecs.component.Component;
import cn.com.twoke.application.game.mario.core.ecs.entity.Entity;
import lombok.Data;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

@Data
public class TransfersComponent implements Component {

    /**
     * 传送门UI调试
     */
    private static Boolean DEBUG = false;


    public static void enableDebug(){
        DEBUG = true;
    }

    public static Boolean isDebug(){
        return DEBUG;
    }


    public enum TransferType {
        ENTRY, EXPORT
    }

    public enum Direction {
        TOP,
        LEFT;
    }

    public List<Transfer> entries = new ArrayList<>();

    public Transfer createTransfer() {
        Transfer transfer = new Transfer();
        entries.add(transfer);
        return transfer;
    }


    @Data
    public static class Transfer {
        public TransferType type = TransferType.ENTRY;
        public Direction direction = Direction.TOP;
        public Shape shape;
        public boolean enabled = false;
        public boolean used = false;
        private String name;
        /**
         * 目标场景
         * 当 type 为
         * {@link TransferType.EXPORT}时必填
         */
        private String targetSceneName;
        private Function<Entity, String> checkinFun;


        public String getKey() {
            return name + "_" + type.name();
        }

        public String getEntryKey() {
            return name + "_" + TransferType.ENTRY.name();
        }

        public String getExportKey() {
            return name + "_" + TransferType.EXPORT.name();
        }

    }

}
